﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace OpenExpressApp.Expression
{
    public static class Functions
    {
        public static object Single(IList list, string filterExpr)
        {
            if (list.Count == 0) return null;
            ObjectExprParser oe = new ObjectExprParser(list[0]);
            oe.Compile(filterExpr);
            foreach(var item in list)
            {
                if ((bool)oe.Evaluate(item)) return item;
            }
            return null;
        }
    }
}
